/*******************************************************************
 * author   :  Charlies-ls
 * Date     :  2021-09-26
 * Function :  implement ax_set base on hashtable
 * Copyright (c) 2021. artestplay@outlook.com. All Rights Reserved.
 *******************************************************************/
#ifndef AX_SET_H_
#define AX_SET_H_

#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "ax_hashtable.h"
#include "ax_list.h"
#ifdef __cplusplus
extern "C" {
#endif

typedef struct ax_set ax_set;

enum
{
  AX_SET_NONE,
  AX_SET_CONST_VALUE  // do not alloc memory internal
};

ax_set* ax_set_create(int type);
void    ax_set_destory(ax_set* s);
void    ax_set_insert(ax_set* s, void* data, size_t data_size);
void    ax_set_remove(ax_set* s, void* data, size_t data_size);
bool    ax_set_contains(ax_set* s, void* data, size_t data_size);
size_t  ax_set_size(ax_set* s);
void    ax_set_clear(ax_set* s);


ax_hashtable* ax_set_hashtable(ax_set* s);
#define ax_set_foreach(data, s) \
for(ax_list_node* __node__=ax_hashtable_get_head(ax_set_hashtable(s));\
     __node__!=(data=ax_hashtable_entry_get_key(__node__), NULL);\
     __node__=__node__->next)

#ifdef __cplusplus
}
#endif

#endif
